# 类也是对象，type创建类的类
def create_class(name):
    if name == "user":
        class User:
            def __str__(self):
                return "user"
        return User
    elif name == "company":
        class Company:
            def __str__(self):
                return "company"
        return Company

def say(self):
    return "i am user"

class BaseClass:
    def answer(self):
        return "i am baseclass"

"""
什么是元类，元类是创建类的类
对象 <- class(对象) <- type
"""

if __name__ == '__main__':
    MyClass = create_class("user")
    my_obj = MyClass()
    print(my_obj)
    print(type(my_obj))

    # User = type("User", (), {"name":"user", "say":say})
    # my_obj = User()
    # print(my_obj.say())

    User = type("User", (BaseClass,), {"name":"user", "say":say})
    my_obj = User()
    print(my_obj.answer())

